home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
tex
/
ptf12.zip
/
PTFTEST.SRC
< prev
Wrap
Text File
|
1990-02-27
|
34KB
|
1,423 lines
--::::::::::
--ptftest.inc
--::::::::::
-- This include file
ptftest.inc
-- Test programs for PTF
err_test.a
foftest1.a
foftest2.a
foftest3.a
foftest4.a
mac_test.a
parsetst.a
var_test.a
wp_test.a
-- Test data files
foftest2.inp
wptest1.in
wptest2.in
wptest2a.in
wptest2b.in
wptest3.in
wptest4.in
wptest5.in
wptest6.in
--::::::::::
--err_test.a
--::::::::::
-- ..................................
-- . .
-- . Err_Test . SPEC & BODY
-- . .
-- ..................................
with Console;
with Error_Log;
with Variable;
procedure Err_Test is
--| Purpose
--| Err_Test provides a simple test of the Error_Log package.
--|
--| Exceptions (none)
--| Notes (none)
--|
--| Modifications
--| 08/23/89 Rick Conn Initial Version
begin -- Err_Test
Variable.Set_File_Name("Err_Test");
Variable.Set_Line_Number(1);
Error_Log.Write_Error("This message should go to the console");
Error_Log.Write_Warning("This message also");
Error_Log.Close;
Error_Log.Open("error.log");
Error_Log.Write_Error("this message appears in the error log file");
Error_Log.Write_Warning("as does this one");
Error_Log.Close;
Console.Put_Line("Test complete -- output on screen and in error.log");
end Err_Test;
--::::::::::
--foftest1.a
--::::::::::
-- ..................................
-- . .
-- . Foftest1 . SPEC & BODY
-- . .
-- ..................................
with Console;
with Formatted_Output_File;
use Formatted_Output_File;
with Text_IO;
procedure Foftest1 is
--| Purpose
--| FofTest1 is a basic test program for the Formatted_Output_File
--| package. It exercises the Put_Line and Break_Page routines
--| primarily.
--|
--| Notes (none)
--|
--| Modifications
--| 8/1/89 Rick Conn Initial version
Output_File
: Formatted_Output_File.File;
File_Name
: constant STRING
:= "foftest1.doc";
Open_Status
: Formatted_Output_File.Status;
begin -- Foftest1
-- Open the output file
Open(Output_File, File_Name, Open_Status);
-- Check for status of open
if Open_Status = Not_Ok then
Text_IO.Put_Line("Cannot open output file");
end if;
-- Set margins
Set_Page_Attribute(Output_File, Left_Margin, 10);
Set_Page_Attribute(Output_File, Right_Margin, 70);
-- Set header lines
Set_Page_Attribute(Output_File, Header_Lines, 2);
Set_Header_Line(Output_File, Even_Pages, 1, "", "", "File Name: "
& File_Name);
Set_Header_Line(Output_File, Odd_Pages, 1,
"File Name: " & File_Name, "", "");
Set_Header_Line(Output_File, All_Pages, 2, "", "", "");
-- Set footer lines
Set_Page_Attribute(Output_File, Footer_Lines, 2);
Set_Footer_Line(Output_File, All_Pages, 1, "", "", "");
Set_Footer_Line(Output_File, Even_Pages, 2, "Page #", "", "");
Set_Footer_Line(Output_File, Odd_Pages, 2, "", "", "Page #");
-- Set No FILL
Set_Line_Attribute(Output_File, Fill, Off);
-- Output 2 lines of numbers
Put_Line(Output_File,
" 1 2 3 4 5 6");
Put_Line(Output_File,
"1234567890123456789012345678901234567890123456789012345678901");
-- Output 46 lines on the first page
for I in 1 .. 46 loop
Put_Line(Output_File, "Page 1, Line Number" & INTEGER'Image(I + 2));
end loop;
-- Output 2 lines of numbers
Put_Line(Output_File,
" 1 2 3 4 5 6");
Put_Line(Output_File,
"1234567890123456789012345678901234567890123456789012345678901");
-- Go to next page
Break_Page(Output_File);
-- Output 2 lines of numbers
Put_Line(Output_File,
" 1 2 3 4 5 6");
Put_Line(Output_File,
"1234567890123456789012345678901234567890123456789012345678901");
-- Output 46 lines on the second page
for I in 1 .. 46 loop
Put_Line(Output_File, "Page 2, Line Number" & INTEGER'Image(I + 2));
end loop;
-- Output 2 lines of numbers
Put_Line(Output_File,
" 1 2 3 4 5 6");
Put_Line(Output_File,
"1234567890123456789012345678901234567890123456789012345678901");
-- Go to next page (Break_Page call is not really necessary)
-- Break_Page(Output_File);
-- Output many lines on the third and following pages
for I in 1 .. 100 loop
Put_Line(Output_File, "Long List, Line Number" & INTEGER'Image(I));
end loop;
-- Close the output file
Close(Output_File);
Console.Put_Line("Test complete -- output in " & File_Name);
end Foftest1;
--::::::::::
--foftest2.a
--::::::::::
-- ..................................
-- . .
-- . Foftest2 . SPEC & BODY
-- . .
-- ..................................
with Console;
with Formatted_Output_File;
use Formatted_Output_File;
with Text_IO;
procedure Foftest2 is
--| Purpose
--| FofTest2 is a basic test program for the Formatted_Output_File
--| package. It tests the Put_Word, Skip_Line, and Break_Line
--| routines primarily.
--|
--| Notes (none)
--|
--| Modifications
--| 08/04/89 Rick Conn Initial version
Input_File
: Text_IO.File_Type;
Output_File
: Formatted_Output_File.File;
Input_File_Name
: constant STRING
:= "foftest2.inp";
Output_File_Name
: constant STRING
:= "foftest2.doc";
Open_Status
: Formatted_Output_File.Status;
Inline
: STRING (1 .. 100);
Inlast
: NATURAL;
First
: NATURAL;
Last
: NATURAL;
Current
: NATURAL;
Program_Halt
: exception;
procedure Process is
begin -- Process
-- Open the input file
Text_IO.Open(Input_File, Text_IO.In_File, Input_File_Name);
-- Main loop
Skip(Output_File, 2);
Put_Word(Output_File, " "); -- start 1st paragraph
while not Text_IO.End_Of_File(Input_File) loop
Text_IO.Get_Line(Input_File, Inline, Inlast);
if Inlast = 0 then
-- Begin a new paragraph (with opening spaces) if a blank line
Skip(Output_File, 2);
Put_Word(Output_File, " ");
else
-- Extract the next word from the input line and
-- output this word to the formatted file
Current := 1;
while Current <= Inlast loop
First := Inlast + 1;
for I in Current .. Inlast loop
if Inline(I) > ' ' then
First := I;
exit;
end if;
end loop;
Current := Inlast + 1;
if First <= Inlast then
Last := Inlast;
for I in First .. Inlast loop
if Inline(I) <= ' ' then
Last := I - 1;
exit;
end if;
end loop;
Put_Word(Output_File, Inline(First .. Last));
Current := Last + 1;
end if;
end loop;
end if;
end loop;
-- End page
Break_Page(Output_File);
-- Close the input file
Text_IO.Close(Input_File);
end Process;
begin -- Foftest2
-- Open the output file
Open(Output_File, Output_File_Name, Open_Status);
-- Check for status of open
if Open_Status = Not_Ok then
Text_IO.Put_Line("Cannot open output file");
raise Program_Halt;
end if;
-- Set margins
Set_Page_Attribute(Output_File, Left_Margin, 10);
Set_Page_Attribute(Output_File, Right_Margin, 70);
-- Set header lines
Set_Page_Attribute(Output_File, Header_Lines, 2);
Set_Header_Line(Output_File, All_Pages, 1, "", "File Name: " &
Output_File_Name, "");
Set_Header_Line(Output_File, All_Pages, 2, "", "", "");
-- Set footer lines
Set_Page_Attribute(Output_File, Footer_Lines, 2);
Set_Footer_Line(Output_Fil